package cn.fairy.springboot.feignclient;

import cn.fairy.springBoot.domain.User;
import feign.hystrix.FallbackFactory;

import org.springframework.stereotype.Component;

//让Spring扫描到该托底类
@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {


    @Override
    public UserFeignClient create(Throwable throwable) {
        return id -> {
            throwable.printStackTrace();
            return User.builder().id(id).desc("用户服务不可用").build();
        };
    }
}